<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=0, viewport-fit=cover" />
	<title>debounce</title>
</head>
<body>

<input id="ipt" value="" />

<script>
ipt.oninput = debounce(function (event) {
	console.log(Date.now(), this, event)
}, 1000)

/*ipt.oninput = function () {
	console.log([...arguments])
}
var o ={
	0:'',
	1:'',
	length: 2
}*/
function debounce(fn, lazy = 800) {
	let timer = null;
	return function () {
		clearTimeout(timer);
		timer = setTimeout(() => {
			fn.apply(this, arguments);
		}, lazy)
	};
};

</script>
</body>
</html>
